﻿using System.Web.Mvc;
using YuYuKiCms.Bl.Interface;
using YuYuKiCms.Framework.Interface;

namespace YuYuKiCms.Internet.Controllers
{
    public class LanguageController : Controller
    {
        private readonly IChangeLanguageBL _changeLanguageBL;
        private readonly IUtil _util;

        public LanguageController(IChangeLanguageBL changeLanguageBL, IUtil util)
        {
            _changeLanguageBL = changeLanguageBL;
            _util = util;
        }

        public ActionResult ChangeCulture(string lang, string returnUrl)
        {
            _util.SetCookie(Response, lang);

            if (_changeLanguageBL.ChangeCulture(Request, lang, ref returnUrl))
                return Redirect(returnUrl);
            return RedirectToAction("Index", "Home", new { language = lang });
        }
    }
}